package common.store.web.controller;

import common.store.admin.dto.Category;
import common.store.admin.service.CategoryService;
import common.store.admin.service.impl.CategoryServiceImpl;
import common.store.web.bean.CartAndProduct;
import common.store.web.bean.User;
import common.store.web.service.CartService;
import common.store.web.service.impl.CartServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/DelAllcartList")
public class CartListDelServlet extends HttpServlet  {
    CartService cartService;
    private CategoryService categoryService;
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        categoryService = new CategoryServiceImpl();

        List<Category> categoryList = categoryService.getCategoryList();
        User user= (User)req.getSession().getAttribute("user");
        String uid= user.getUid();
        req.setAttribute("categoryList" , categoryList);
        System.out.println(uid+"-------");
        cartService = new CartServiceImpl();
        cartService.deleteALLCartById(uid);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req , resp);
    }
}
